package com.digdes.calendar.model.impl;

/**
 * User: Dmitry
 * Date: 31.03.12
 * Time: 16:32
 */

import com.digdes.calendar.gwt.client.dto.EventDTOImpl;
import com.digdes.calendar.gwt.client.dto.EventParticipantDTOImpl;
import com.digdes.calendar.model.*;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;


public class EventImpl implements Event {
    private Long id;
    private String nameEvent;
    private String description;
    private boolean isAllDay;
    private boolean isNeedNotice;
    private Date dateStart;
    private Date dateFinish;
    private String myPlace;
    private Set<File> files = new HashSet<File>(0);
    private Place place;
    private User author;
    private Set<EventParticipant> participants = new HashSet<EventParticipant>(0);

    public EventImpl() {
    }

    public EventImpl(Long id) {
        this.id = id;
    }

    /*public int hashCode() {
        return (int) id;
    }*/
    public EventImpl(EventDTOImpl eventDTO) {
        this.id = eventDTO.getId();
        this.nameEvent = eventDTO.getNameEvent();
        this.description = eventDTO.getDescription();
        this.dateStart = eventDTO.getDateStart();
        this.dateFinish = eventDTO.getDateFinish();
        this.myPlace = eventDTO.getMyPlace();
        //this.files = new FileImpl(eventDTO.getFiles());
        Set<EventParticipant> participants = new HashSet<EventParticipant>(0);
        for (EventParticipantDTOImpl participant : eventDTO.getParticipants()) {
            participants.add(new EventParticipantImpl(participant));
        }
        this.participants = participants;
        this.author = new UserImpl(eventDTO.getAuthor());
        this.place = new PlaceImpl(eventDTO.getPlace());

    }

    public boolean equals(Object o) {
        if(!(o instanceof Event)) return false;
        Event e = (Event) o;
        return e.getId() == this.id;
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNameEvent() {
        return this.nameEvent;
    }

    public void setNameEvent(String nameEvent) {
        this.nameEvent = nameEvent;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public boolean getIsAllDay() {
        return this.isAllDay;
    }

    public void setIsAllDay(boolean isAllDay) {
        this.isAllDay = isAllDay;
    }

    public boolean getIsNeedNotice() {
        return this.isNeedNotice;
    }

    public void setIsNeedNotice(boolean isNeedNotice) {
        this.isNeedNotice = isNeedNotice;
    }

    public Date getDateStart() {
        return this.dateStart;
    }

    public void setDateStart(Date dateStart) {
        this.dateStart = dateStart;
    }

    public Date getDateFinish() {
        return this.dateFinish;
    }

    public void setDateFinish(Date dateFinish) {
        this.dateFinish = dateFinish;
    }

    public String getMyPlace() {
        return this.myPlace;
    }

    public void setMyPlace(String myPlace) {
        this.myPlace = myPlace;
    }

    public Set<File> getFiles() {
        return this.files;
    }

    public void setFiles(Set<File> files) {
        this.files = files;
    }

    public Place getPlace() {
        return this.place;
    }

    public void setPlace(Place place) {
        this.place = place;
    }

    public User getAuthor() {
        return this.author;
    }

    public void setAuthor(User author) {
        this.author = author;
    }

    public Set<EventParticipant> getParticipants() {
        return this.participants;
    }

    public void setParticipants(Set<EventParticipant> participants) {
        this.participants = participants;
    }


}
